package cc.shacocloud.kotlin.tools.cli

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import picocli.CommandLine
import picocli.CommandLine.Option

/**
 *
 * @author 思追(shaco)
 */
class CommandLineRunnableTest {

    @Test
    fun setUp() {
        val exitCode: Int = CommandLine(CommandLineRunnable())
            .execute(*arrayOf("-a", "参数1", "-l", "list1"))

        assertEquals(0, exitCode)
    }


}

class CommandLineRunnable : Runnable {

    @Option(names = ["-a", "--arg"], description = ["脚本的第一个参数"], required = true)
    lateinit var arg1: String

    @Option(names = ["-l", "--list"], description = ["脚本的集合参数"])
    var list: Array<String> = emptyArray()

    override fun run() {
        println("arg1: $arg1")
        println("list: ${list.contentToString()}")
    }

}